package org.rapan;

import org.rapan.jpa.Consultant;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Label;

@SuppressWarnings("serial")
public class UserLogoLayout extends VerticalLayout {
	Button logout = new Button("Logout");
	Label greet;

	UserLogoLayout(final Consultant c) {
		super();
		if (c != null) {

			greet = new Label("<h2>" + c.getFullName() + "</h2>");
			greet.setContentMode(Label.CONTENT_XHTML);
			addComponent(greet);
			addComponent(logout);
			setComponentAlignment(greet, Alignment.TOP_RIGHT);
			setComponentAlignment(logout, Alignment.MIDDLE_RIGHT);

		} else {
		}
		greet.setSizeUndefined();

		setMargin(false);

		logout.addListener(new ClickListener() {

			public void buttonClick(ClickEvent event) {
				getApplication().close();

			}
		});
	}
}
